package org.dubbo.demo.provider;

import java.text.SimpleDateFormat;
import java.util.Date;

import org.dubbo.demo.api.DemoService;

import com.alibaba.dubbo.config.annotation.Service;
import com.alibaba.dubbo.rpc.RpcContext;

//import org.dubbo.demo.api.DemoService;
@Service(
        version = "1.0.0",
        application = "${dubbo.application.id}",
        protocol = "${dubbo.protocol.id}",
        registry = "${dubbo.registry.id}"
)
public class DemoServiceImpl implements DemoService{

	public String sayHello(String name) {
		
		 System.out.println("[" + new SimpleDateFormat("HH:mm:ss").format(new Date()) + "] Hello " + name + ", request from consumer: " + RpcContext.getContext().getRemoteAddress());
	     return "Hello " + name + ", response from provider: " + RpcContext.getContext().getLocalAddress();
	}

}
